{include file="header/index" /}
<meta charset="UTF-8">
<link rel="stylesheet" href="__JS__/layui/css/layui.css"/>
<style>
    .form-control {
        height: 33px;
    }
    .size100{
        width: 100px !important;
        height: 100px !important;

    }
    .shuffling_pic{
        margin: 10px;
    }
    .enclosureitem i{
        width: 20px;
        height: 20px;
        line-height: 20px !important;
        text-align: center;
        color:red;
        border: 1px solid red;
    }
    .backbtn{
        margin-top: -10px;
    }
    .pca{
        display: flex;
        width: 82% !important;
        margin-top: 10px;
    }
    .ding{
        width: 53% !important;
        display: flex;
    }
</style>

<body>
<div class="container wrapper-content animated fadeInRight add_new_user whitebg fixedFather">
    <h3 class="title fix">
        修改城市TDS
        <span class="newNotice"><span class="newtext">*</span>为必填项</span>
        <div class="backbtnwrap fr">
            <button type="button" class="btn backbtn newBtnDefault newBtnGray" onclick="returnBack(this)"> <i class="fa fa-mail-reply"></i>返回</button>
        </div>
    </h3>
    <form method="post" action="{:url('Config/editTds')}" enctype="multipart/form-data" id="myform">
        <!-- 基本信息 -->
        <div class="newPart" style="padding-top:50px;">
            <div class="newTitle">
                <img src="__IMG__/icon4.png" class="icon">基本信息
            </div>
            <div class="newContent clearFlex">
                <div class="newOne">
                    <input name="id" type="hidden" value="{$data.id}">
                    <div class="col-sm-6 ding">
                        <div class="col-sm-3 inputText"><span class="newtext">*</span>城市</div>
                        <div class="col-sm-7 pca">
                            <select name="p_name" onchange="selectP()">
                                <option value="">请选择省份</option>
                                {volist name="p_name" id="vo"}
                                <option value="{$vo.id}"{if condition="$data.p_code == $vo.id"}selected{/if}>{$vo.area_name}</option>
                                {/volist}
                            </select>
                            <select name="c_name" onchange="selectC()">
                                <option value="">请选择市级</option>
                                {volist name="c_name" id="vo"}
                                <option value="{$vo.id}" {if condition="$data.c_code == $vo.id"}selected{/if}>{$vo.area_name}</option>
                                {/volist}
                            </select>
                            <select name="a_name">
                                <option value="">请选择区县</option>
                                {volist name="a_name" id="vo"}
                                <option value="{$vo.id}" {if condition="$data.a_code == $vo.id"}selected{/if}>{$vo.area_name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="newOne">
                    <div class="col-sm-6">
                        <div class="col-sm-3 inputText"><span class="newtext">*</span>TDS</div>
                        <div class="col-sm-7">
                            <input type="text" name="tds" value="{$data.tds}" onkeyup="(this.v=function(){this.value=this.value.replace(/[^0-9-]+/,'');}).call(this)" onblur="this.v();" placeholder="该城市的TDS值">
                        </div>
                    </div>
                </div>
                <div class="newOne">
                    <div class="col-sm-12">
                        <div class="col-sm-2">&nbsp;</div>
                        <div class="col-sm-10">
                            <button class="btn btn-primary mr30 newBtnDefault newBtnPrimary" type="submit">保存</button>
                            <a href="javascript:(0)" class="btn btn-default mr30 newBtnDefault" onclick="reset()">重置</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
</body>

<script type="text/javascript" src="__JS__/layui/layui.js"></script>
<script>
    function selectP(){
        $("select[name='c_name']").empty();
        var init_html = '<option value="">请选择市级</option>';
        $("select[name='c_name']").append(init_html);
        $("select[name='a_name']").empty();
        var init_html_t = '<option value="">请选择区县</option>';
        $("select[name='a_name']").append(init_html_t);
        var id = $("select[name='p_name'] option:selected").val();
        $.post("{:url('Config/getAddress')}",{id:id},function (flag) {
            if (flag.code < 0){
                layer.msg(flag.msg, {icon: 0});
                return false;
            }
            $.each(flag.data,function (k,v) {
                var html = '<option value="'+v.id+'">'+v.area_name+'</option>';
                $("select[name='c_name']").append(html);
            })
        });
    }
    function selectC(){
        $("select[name='a_name']").empty();
        var init_html = '<option value="">请选择区县</option>';
        $("select[name='a_name']").append(init_html);
        var id = $("select[name='c_name'] option:selected").val();
        $.post("{:url('Config/getAddress')}",{id:id},function (flag) {
            if (flag.code < 0){
                layer.msg(flag.msg, {icon: 0});
                return false;
            }
            $.each(flag.data,function (k,v) {
                var html = '<option value="'+v.id+'">'+v.area_name+'</option>';
                $("select[name='a_name']").append(html);
            })
        });
    }
    $(function(){
        $('#myform').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });

        function checkForm(){
            if ($("select[name='p_name']").val() == '') {
                layer.msg('请选择省份', {icon: 0});
                return false;
            }
            if ($("select[name='c_name']").val() == '') {
                layer.msg('请选择市级', {icon: 0});
                return false;
            }
            if ($("select[name='a_name']").val() == '') {
                layer.msg('请选择区县', {icon: 0});
                return false;
            }
            if ($("input[name='tds']").val() == '') {
                layer.msg('请输入TDS值', {icon: 0});
                return false;
            }
        }
        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 1,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('Config/settingTdsList')}";
                });
            }else{
                layer.msg(data.msg, {icon: 2,time:1500,shade: 0.1});
                return false;
            }
        }

    });
    //重置
    function reset() {
        top.layer.confirm('你确定要重置吗?', {
            btn: ['确定', '取消'] //按钮
        }, function() {
            $("form")[0].reset();
            top.layer.msg('重置成功', {
                icon: 1
            });
        });
    }
</script>

</html>